#ifndef EFFECT_MANAGER_H
#define EFFECT_MANAGER_H
#include <map>
#include <vector>
#include <string>
#include "GameObject.h"
#include "Camera.h"
#include "Effect.h"
#include "Singleton.h"
#include "dxut/DXUT.h"


#pragma comment( lib, "comctl32.lib" )
#pragma comment( lib, "DXErr.lib" )

struct VERTEX
{
	D3DXVECTOR4 pos;
	DWORD clr;
	D3DXVECTOR2 tex1;
	D3DXVECTOR2 tex2;
	D3DXVECTOR2 tex3;
	D3DXVECTOR2 tex4;
	D3DXVECTOR2 tex5;
	D3DXVECTOR2 tex6;

	static const DWORD FVF;
};


class EffectManager
{
public:
	void Init();
	void AddEffect(std::string name, Effect* e);
	Effect* Get(std::string name);
	void Render(std::string name, Camera* camera, std::vector<GameObject*> GO);
	void BasicRender(Camera* camera, std::vector<GameObject*> GO);
	void Clean();
	void SetWireframe(bool b){m_bWireframe = b;}
	bool GetWireframe(){return m_bWireframe;}
	bool GetBasic(){return m_bBasicRender;}
	void SetBasic(bool b){m_bBasicRender=b;}
private:
	std::map<std::string, Effect*> m_EffectMap;
	EffectManager();
	friend class Singleton<EffectManager>;

	LPDIRECT3DTEXTURE9 m_pBlurTex; 
	LPDIRECT3DSURFACE9 m_pBlurSurf;
	LPD3DXRENDERTOSURFACE m_pRenderToSurface;
	D3DVIEWPORT9 m_ViewportFB;
	D3DVIEWPORT9 m_ViewportOffscreen;
	IDirect3DSurface9* m_pBackBuffer;
	D3DSURFACE_DESC m_pBackBufferSurfaceDesc;
	D3DXVECTOR4 m_vFocalPlane;
	VERTEX m_Vertex[4];
	bool m_bBasicRender;	
	bool m_bWireframe;
};
typedef Singleton<EffectManager> TheEffectManager;
#endif